{{ ansible_managed | comment }}

server {
    listen {{ nginx_config_rest_api_port | default('8080') }};
{% if nginx_config_rest_api_access_log is defined %}
    access_log{{ ' off' if not nginx_config_rest_api_access_log }}{{ (' ' + nginx_config_rest_api_access_log.location) if nginx_config_rest_api_access_log.location is defined }}{{ (' ' + nginx_config_rest_api_access_log.name) if nginx_config_status_rest_api_log.name is defined }};
{% endif %}
    location /api {
{% if nginx_config_rest_api_write is defined %}
        api{{ ' write=on' if nginx_config_rest_api_write }};
{% endif %}
{% if nginx_config_rest_api_allow is defined %}
{% for address in nginx_config_rest_api_allow %}
        allow {{ address }};
{% endfor %}
{% endif %}
{% if nginx_config_rest_api_deny is defined %}
{% for address in nginx_config_rest_api_deny %}
        deny {{ address }};
{% endfor %}
{% endif %}
    }
{% if nginx_config_rest_api_dashboard is defined and nginx_config_rest_api_dashboard %}
    location = /dashboard.html {
        root /usr/share/nginx/html;
{% if nginx_config_rest_api_dashboard_allow is defined %}
{% for address in nginx_config_rest_api_dashboard_allow %}
        allow {{ address }};
{% endfor %}
{% endif %}
{% if nginx_config_rest_api_dashboard_deny is defined %}
{% for address in nginx_config_rest_api_dashboard_deny %}
        deny {{ address }};
{% endfor %}
{% endif %}
    }
{% endif %}
}
